package cn.lanqiao.test;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;

import cn.lanqiao.entity.User;
import cn.lanqiao.util.ReadFile;
import java.awt.Font;

public class UserFrm extends JFrame {
	private JPanel contentPane;
	private User user;
	/**
	 * Create the frame.
	 */
	public UserFrm(User user) {
		this.user = user;
		setTitle("用户主页");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 789, 633);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JPanel panel = new JPanel();
		panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel.setBounds(10, 13, 367, 217);
		contentPane.add(panel);
		panel.setLayout(null);

		JLabel lblNewLabel = new JLabel("New label");
		lblNewLabel.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\用户头像.jpg"));// 加载用户头像
		lblNewLabel.setBounds(0, 0, 204, 217);
		panel.add(lblNewLabel);

		JLabel lblId = new JLabel("ID");
		lblId.setBounds(218, 24, 72, 18);
		panel.add(lblId);

		JLabel lblNewLabel_1 = new JLabel("new label");
		lblNewLabel_1.setBounds(218, 55, 122, 18);
		lblNewLabel_1.setText(this.user.getUserID());
		panel.add(lblNewLabel_1);

		JLabel label = new JLabel("个性签名");
		label.setBounds(218, 86, 72, 18);
		panel.add(label);

		JLabel lblNewLabel_2 = new JLabel("new label");
		lblNewLabel_2.setBounds(218, 117, 135, 18);
		lblNewLabel_2.setText(this.user.getSign());
		panel.add(lblNewLabel_2);

		JLabel label_1 = new JLabel("最后登录时间");
		label_1.setBounds(218, 148, 97, 18);
		panel.add(label_1);

		SimpleDateFormat slf = new SimpleDateFormat("yyyy-MM-dd");

		JLabel lblNewLabel_3 = new JLabel("new label");
		lblNewLabel_3.setBounds(218, 179, 104, 18);
		lblNewLabel_3.setText((slf.format(new Date())));
		panel.add(lblNewLabel_3);

		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_1.setBounds(10, 243, 759, 171);
		contentPane.add(panel_1);
		panel_1.setLayout(null);

//			JLabel label_2 = new JLabel("段位");
//			label_2.setBounds(39, 140, 30, 18);
//			panel_1.add(label_2);

		JLabel lblNewLabel_4 = new JLabel("New label");
		lblNewLabel_4.setBounds(46, 31, 94, 96);
		lblNewLabel_4.setIcon(
				new ImageIcon(ReadFile.readFile("src\\cn\\lanqiao\\source\\U_Level\\", this.user.getU_Level())));
		panel_1.add(lblNewLabel_4);

		JLabel label_3 = new JLabel("总场次");
		label_3.setFont(new Font("宋体", Font.PLAIN, 18));
		label_3.setBounds(239, 31, 72, 18);
		panel_1.add(label_3);

		JLabel label_4 = new JLabel("胜场数");
		label_4.setFont(new Font("宋体", Font.PLAIN, 18));
		label_4.setBounds(388, 31, 72, 18);
		panel_1.add(label_4);

		JLabel lblMvp = new JLabel("MVP场数");
		lblMvp.setFont(new Font("宋体", Font.PLAIN, 18));
		lblMvp.setBounds(527, 31, 72, 18);
		panel_1.add(lblMvp);

		JLabel label_5 = new JLabel("战斗力");
		label_5.setFont(new Font("宋体", Font.PLAIN, 18));
		label_5.setBounds(239, 109, 72, 18);
		panel_1.add(label_5);

		JLabel label_6 = new JLabel("英雄数");
		label_6.setFont(new Font("宋体", Font.PLAIN, 18));
		label_6.setBounds(388, 109, 72, 18);
		panel_1.add(label_6);

		JLabel label_7 = new JLabel("皮肤数");
		label_7.setFont(new Font("宋体", Font.PLAIN, 18));
		label_7.setBounds(527, 109, 72, 18);
		panel_1.add(label_7);

		JLabel lblNewLabel_5 = new JLabel("New label");
		lblNewLabel_5.setBounds(239, 62, 72, 18);
		lblNewLabel_5.setText(new Integer(this.user.getTotalNum()).toString());// 用户总场次
		panel_1.add(lblNewLabel_5);

		JLabel lblNewLabel_6 = new JLabel("New label");
		lblNewLabel_6.setBounds(388, 62, 72, 18);
		lblNewLabel_6.setText(new Float(this.user.getWinNum()).toString());
		panel_1.add(lblNewLabel_6);

		JLabel lblNewLabel_7 = new JLabel("New label");
		lblNewLabel_7.setBounds(527, 62, 72, 18);
		lblNewLabel_7.setText(new Integer(this.user.getMVPNum()).toString());
		panel_1.add(lblNewLabel_7);

		JLabel lblNewLabel_8 = new JLabel("New label");
		lblNewLabel_8.setBounds(239, 140, 72, 18);
		lblNewLabel_8.setText(new Integer(this.user.getFC()).toString());
		panel_1.add(lblNewLabel_8);

		JLabel lblNewLabel_9 = new JLabel("New label");
		lblNewLabel_9.setBounds(388, 140, 72, 18);
		lblNewLabel_9.setText(new Integer(this.user.getHeroNum()).toString());
		panel_1.add(lblNewLabel_9);

		JLabel lblNewLabel_10 = new JLabel("New label");
		lblNewLabel_10.setBounds(527, 140, 72, 18);
		lblNewLabel_10.setText(new Integer(this.user.getSkinNum()).toString());
		panel_1.add(lblNewLabel_10);

		JLabel lblNewLabel_20 = new JLabel("New label");
		lblNewLabel_20.setBounds(56, 140, 72, 18);
		lblNewLabel_20.setText(this.user.getU_Level());
		panel_1.add(lblNewLabel_20);

		JLabel lblNewLabel_14 = new JLabel("New label");
		lblNewLabel_14.setBounds(0, 0, 759, 171);
		lblNewLabel_14.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\UserFrm背景图片.jpg"));
		panel_1.add(lblNewLabel_14);

		JPanel panel_3 = new JPanel();
		panel_3.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_3.setBounds(390, 13, 379, 217);
		contentPane.add(panel_3);
		panel_3.setLayout(null);

		JLabel lblNewLabel_12 = new JLabel("英雄头像");
		lblNewLabel_12.setBounds(10, 10, 57, 23);
		panel_3.add(lblNewLabel_12);

		JLabel lblNewLabel_13 = new JLabel("New label");
		lblNewLabel_13.setBounds(20, 35, 336, 172);
		lblNewLabel_13.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\吕布头像.jpg"));
		panel_3.add(lblNewLabel_13);

		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_2.setBounds(10, 421, 759, 164);
		contentPane.add(panel_2);
		panel_2.setLayout(null);
		
		JButton button_3 = new JButton("退出程序");
		button_3.setBounds(619, 19, 126, 127);
		button_3.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\按钮背景5.jpg"));
		button_3.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				int option = JOptionPane.showConfirmDialog(null, "确认退出?", "退出窗口", JOptionPane.YES_NO_OPTION);
				if (option == 0) {
					System.exit(0);
				}
			}
		});
		panel_2.add(button_3);
		
		JButton button_2 = new JButton("好友列表");
		button_2.setBounds(465, 19, 126, 127);
		button_2.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\按钮背景4.jpg"));
		panel_2.add(button_2);
		
		JButton button_1 = new JButton("常用英雄");
		button_1.setBounds(316, 19, 126, 127);
		button_1.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\按钮背景3.jpg"));
		panel_2.add(button_1);
		
		JButton button = new JButton("英雄池");
		button.setBounds(165, 19, 126, 127);
		button.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\按钮背景2.jpg"));
		panel_2.add(button);
		
		JButton button_4 = new JButton("历史战绩");
		button_4.setBounds(14, 19, 126, 127);
		button_4.setIcon(new ImageIcon("src\\cn\\lanqiao\\source\\按钮背景1.jpg"));		
		panel_2.add(button_4);
		this.setResizable(false);

	}	
}

